`
https://leetcode.cn/problems/container-with-most-water/
`

/**
 * @param {number[]} height
 * @return {number}
 */
var maxArea = function (height) {
  let left = 0, right = height.length - 1
  let res = 0

  while (left < right) {
    // [left, right] 围成的能容纳最多水量的矩形面积
    const curArea = Math.min(height[right], height[left]) * (right - left)
    res = Math.max(res, curArea)
    // 双指针技巧，移动较低的一边
    if (height[left] < height[right]) {
      left++;
    } else {
      right--;
    }
  }

  return res
};